package gases.as3.testing
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	import gases.as3.librarys.components.events.LoadDataEvent;
	import gases.as3.librarys.components.events.TreeEvent;
	import gases.as3.librarys.components.skin.SkinStylesMangaer;
	import gases.as3.librarys.components.skin.data.BaseSkin;
	import gases.as3.librarys.components.swf.StyleConfig;
	import gases.as3.librarys.components.ui.control.GList;
	import gases.as3.librarys.components.ui.control.GScrollBar;
	import gases.as3.librarys.components.ui.control.Tree;
	
	public class TestingAllComponents extends Sprite
	{
		public function TestingAllComponents()
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			instance = StyleConfig.instance;
			instance.addEventListener(LoadDataEvent.LOAD_COMPLETE,onComplete);
		}
		
		private function onComplete(e:Event):void
		{
			
//			var btn:GLabelButton = new GLabelButton("你好啊");
//			btn.skin = btnGreenSkin;
//			btn.selectState = false;
//			btn.isSelect = false;
//			btn.x =  53;
//			btn.y =  25;
//			this.addChild(btn);
//			
//			var cb:GCheckBox = new GCheckBox("你好",0xFF00FF);
//			cb.skin = btnGreenSkin;
//			cb.x = 60;
//			cb.y = 80;
////			cb.text = "你好世界时间诶";
//			this.addChild(cb);
//			
////			var label:GLabel = new GLabel("你好你好");
////			this.addChild(label);
//			
//			var _panel:GPanel = new GPanel(400,300); 
//			_panel.skin = panelSkin;
//			_panel.x = 600;
//			this.addChild(_panel);
//			var _title:GTitle = new GTitle(400,25,"hello world",0x000000); 
//			_title.skin = titleSkin;
//			_panel.addChild(_title);
//			
//			var _pt:GPanelWithTitle = new GPanelWithTitle(400,300,400,25,"soga");
//			_pt.setSkin(panelSkin,titleSkin);
//			_pt.x =  300;
//			_pt.y =  99;
//			this.addChild(_pt);
//			
////			_pt.addChild(btn);
//			
			_tree = new Tree(); 
			_tree.x =100;
			_tree.y =100;
			_tree.treeWidth = 180;
			_tree.skin = SkinStylesMangaer.instance.getSkinData("default_tree") as BaseSkin;
			_tree.dataProvider = xml;
			_tree.addEventListener(TreeEvent.CHANGE_HEIGHT,changeHeight);
//			_tree.addEventListener(TreeEvent.CLICK_NODE,clickNode);
			this.addChild(_tree);
//			
			scrollBar= new GScrollBar(180,150,_tree);
			scrollBar.x = 280;
			scrollBar.y = 100;
			this.addChild(scrollBar);
//			
//			var iconBmd:BitmapData = (iconlistSkin as IconCellListSkin).icon as BitmapData;
//			var iconlist:IconCellList = new IconCellList(4,6,2,2,30,30);
//			this.addChild(iconlist);
//			iconlist.x = 400;
//			iconlist.skin = iconlistSkin;
//			for(var i:int = 0;i< 24;i ++)
//			{
//				iconlist.updateDrawCell(i,iconBmd,"xx"+i);
//			}
//			
			list = new GList();
			list.x = 700;
			this.addChild(list);
//			
//			dp = new Array();
//			dp.push( {label:"Item 1",icon:iconBmd } );
//			dp.push( {label:"Item 2",icon:iconBmd } );
//			dp.push( {label:"Item 335" ,icon:iconBmd} );
//			dp.push( {label:"Item 346" ,icon:iconBmd} );
//			dp.push( {label:"Item 346" ,icon:iconBmd} );
//			dp.push( {label:"Item 3243" ,icon:iconBmd} );
//			dp.push( {label:"Item 346" ,icon:iconBmd} );
//			dp.push( {label:"Item 3234" ,icon:iconBmd} );
//			dp.push( {label:"Item 346" ,icon:iconBmd} );
//			dp.push( {label:"Item 324" ,icon:iconBmd} );
//			dp.push( {label:"Item 324" ,icon:iconBmd} );
//			dp.push( {label:"Item 346" ,icon:iconBmd} );
//			dp.push( {label:"Item 3456" ,icon:iconBmd} );
//			dp.push( {label:"Item 463" ,icon:iconBmd} );
//			dp.push( {label:"Item 3243" ,icon:iconBmd} );
//			dp.push( {label:"Item 346" ,icon:iconBmd} );
//			dp.push( {label:"Item 3456" ,icon:iconBmd} );
//			dp.push( {label:"Item 67" ,icon:iconBmd} );
//			
//			list.dataProvider= dp;
//			
//			scrollBar1= new GScrollBar(90,150,list,true);
//			scrollBar1.skin = btnScrollBgSkin;
//			scrollBar1.x = 790;
//			this.addChild(scrollBar1);
//			
//			var gcb:GComboBox = new GComboBox("asd",120,dp,true);
//			gcb.setSkin(btnGreenSkin,btnScrollBgSkin);
//			gcb.x = 500;
//			gcb.y = 300;
//			this.addChild(gcb);
			
		}
		
		private function changeHeight(e:TreeEvent):void
		{
			scrollBar.updateScroll();
			trace(e.data);
		}
		private var dp:Array;
		private var list:GList;
		private var _tree:Tree;
		private var scrollBar:GScrollBar;
		private var scrollBar1:GScrollBar;
		private var instance:StyleConfig;
		public static var xml:XML = <root>
												  <node label="first node" id="first">
													<node label="first leaf" id="1_1" data="show first leaf"/>
													<node label="second leaf"id="1_2" data="show second leaf"/>
												 </node>
												 <node label="second node" id="second">
													<node label="first component" id="2_1" data="show first component">
														<node label="second first leaf" id="2_1_1" data="second show first leaf"/>
													</node>
													<node label="second component"id="2_2" data="show second component">
														<node label="second second leaf" id="2_2_1" data="second show second leaf"/>
														<node label="second second leaf" id="2_2_2" data="second show second leaf"/>
													</node>
												 </node>
												 <node label="second node" id="second">
													<node label="first component" id="2_1" data="show first component">
														<node label="second first leaf" id="2_1_1" data="second show first leaf"/>
													</node>
													<node label="second component"id="2_2" data="show second component">
														<node label="second second leaf" id="2_2_1" data="second show second leaf"/>
														<node label="second second leaf" id="2_2_2" data="second show second leaf"/>
													</node>
												 </node>
												 <node label="second node" id="second">
													<node label="first component" id="2_1" data="show first component">
														<node label="second first leaf" id="2_1_1" data="second show first leaf"/>
													</node>
													<node label="second component"id="2_2" data="show second component">
														<node label="second second leaf" id="2_2_1" data="second show second leaf"/>
														<node label="second second leaf" id="2_2_2" data="second show second leaf"/>
													</node>
												 </node>
											 </root>;
	}
}